import serial

# 想通过串行端口读写数据，典型场景就是和一些硬件设备进行数据读写
# pip3 install pySerial
def demo_1():
    ser = serial.Serial('/dev/tty.usbmodem641', baudrate=9600, bytesize=8, parity='N', stopbits=1)
    ser.write(b'G1 X50 Y50\r\n')
    resp = ser.readline()
    print(resp)


if __name__ == '__main__':
    demo_1()